***JOP Kane, Mason, and Wronski****
***Maintext Figures and Tables -- Qualtrics Survey data***
 use "JOP_KMW_Qualtrics.dta" file

*********************correlation of correctly placing groups with political knowledge & interest
	**Qualtrics **use "JOP_WatP_Qualtrics.dta" file
pwcorr PlaceDemGroupsCorrect2_01 PlaceRepGroupsCorrect2_01 polint01, sig star(.05)

*Incorrect Placement
tab1 PlaceDemGroupsINCorrect2 PlaceRepGroupsINCorrect2

*********************Figure 2: Sentiments Toward Party Coalitions & Party Identification************
reg pid DemGroups_pfscore GOPgroups_pfscore   ///
PlaceDemGroupsCorrect2_01 PlaceRepGroupsCorrect2_01 ///
polint01 c.age01 edu01 inc01 female  ///
black hispanic other_race /// white= baseline
catholic mormon jewish other_rel no_rel_or_refuse religiosity01, robust // protestant= baseline

coefplot, drop(_cons) ci(95) xline(0) scheme(plottig) xlabel(-2(.5)2)  ///
coeflabels (DemGroups_pfscore = "{bf: Democratic Coalition Score}" GOPgroups_pfscore = "{bf: Republican Coalition Score}" ///
PlaceDemGroupsCorrect2_01 = "Perceptual Accuracy (Dem Groups)" PlaceRepGroupsCorrect2_01 = "Perceptual Accuracy (Rep Groups)" ///
polint01= "Political Interest" age01 = "Age" edu01 = "Education" inc01 = "Income" female = "Female" ///
black = "African-American" hispanic = "Hispanic" other_race = "Other Racial Identification" ///
catholic = "Catholic" mormon = "Mormon" jewish = "Jewish" other_rel= "Other Religious Identification" no_rel_or_refuse="No Religion / No Answer" ///
religiosity01= "Religiosity") 

*Effect Sizes Discussed in Text
* margins across the IQR.  Input the lower and upper bound of the IQR for each party */	
	*25th and 75th percentile values for each factor
	**Dem groups 3.18 - 4.17
sum DemGroups_pfscore, d
	*model same as above for Figure 2
margins, at(DemGroups_pfscore=(-.638 .674))

	**Rep groups 4.18 - 3.25
sum GOPgroups_pfscore, d
	*model same as above for Figure 2
margins, at(GOPgroups_pfscore=(-.549 .622))
	
**predicted values of PID under certain traits
**White, High Warmth for GOP groups, & above average perceptual accuracy	
	*Percentile Values for Perceptual Accuracy variables
sum PlaceDemGroupsCorrect2_01 PlaceRepGroupsCorrect2_01, d
	*model same as above for Figure 2
margins if white==1 & GOPgroups_pfscore>=.622 & PlaceDemGroupsCorrect2_01>=.46 ///
	& PlaceRepGroupsCorrect2_01>=.50, at(DemGroups_pfscore=(.674 -.638)) 


********************Figure 3: Sentiments Toward Party Coalitions, Perceptual Accuracy, and Party ID************
reg pid DemGroups_pfscore GOPgroups_pfscore   ///
PlaceDemGroupsCorrect2_01 PlaceRepGroupsCorrect2_01 ///
c.DemGroups_pfscore#c.PlaceDemGroupsCorrect2_01 c.GOPgroups_pfscore#c.PlaceRepGroupsCorrect2_01 /// interaction term
polint01 c.age01 edu01 inc01 female  ///
black hispanic other_race /// white= baseline
catholic mormon jewish other_rel no_rel_or_refuse religiosity01, robust // protestant= baseline

margins, dydx(DemGroups_pfscore) at(PlaceDemGroupsCorrect2_01=(0(.2)1)) 

marginsplot, level(95) recastci(rarea) ciopts(fcolor(gs2%35) fintensity(55) lcolor(gs8%75) lpattern(dash)) ///
plotopts(msymbol(T) mcolor(black)) ///
scheme(plotplain)  yline(0) ///
addplot(hist PlaceDemGroupsCorrect2_01,  title( " ") ylabel(-1(.5)1) ytitle("{bf: Conditional Effect of Democratic-Groups Sentiments on PID}", size(small)) ///
xtitle("{bf: Perceptual Accuracy (Democratic Groups)}", size(medsmall)) ///
yaxis(2) yscale(alt axis(2)) percent ///
ylabel(0 "0%" 2.5 "2.5%" 5 "5%" 7.5 "7.5%" 10 "10%" 12.5 "12.5%" 15 "15%" 17.5 "17.5%" 20 "20%", labcolor(black*.9) axis(2)) ///
ytitle("{it: Percent of Sample}", axis(2) orientation(rvertical))  fcolor(white%10) lcolor(black*.5)) ///
legend(off) ///
xsize(6.5) ysize(4.5) graphregion(margin(vsmall)) ///
name(g1,replace)

margins, dydx(GOPgroups_pfscore) at(PlaceRepGroupsCorrect2_01=(0(.2)1)) 

marginsplot, level(95) recastci(rarea) ciopts(fcolor(gs2%35) fintensity(55) lcolor(gs8%75) lpattern(dash)) ///
plotopts(msymbol(T) mcolor(black)) ///
scheme(plotplain) yline(0) ///
addplot(hist PlaceRepGroupsCorrect2_01,  title( " ") ylabel(-1(.5)1) ytitle("{bf: Conditional Effect of Republican-Groups Sentiments on PID}", size(small)) ///
xtitle("{bf: Perceptual Accuracy (Republican Groups)}", size(medsmall)) ///
yaxis(2) yscale(alt axis(2)) percent ///
ylabel(0 "0%" 2.5 "2.5%" 5 "5%" 7.5 "7.5%" 10 "10%" 12.5 "12.5%" 15 "15%" 17.5 "17.5%" 20 "20%", labcolor(black*.9) axis(2)) ///
ytitle("{it: Percent of Sample}", axis(2) orientation(rvertical))  fcolor(white%10) lcolor(black*.5)) ///
legend(off) ///
xsize(6.5) ysize(4.5) graphregion(margin(vsmall)) ///
name(g2,replace)

graph combine g1 g2, ycommon iscale(.6) graphregion(margin(tiny))
	
